#include "gasdetection.h"
#include "globalvars.h"

#include "ohos_init.h"
#include "cmsis_os2.h"
#include <unistd.h>
int g_gas_flag = 0;
float g_gas = 0.0f;

void Gasdetection_task()
{
    while(1) {
        Gasdetection(&g_gas);

        if(g_gas > 30)
        {
            g_gas_flag = 1;
        }
        else
        {
            g_gas_flag = 0;
        }
        usleep(3 * 1000 * 1000);
    }
}

void Gasdetection_entry(void)
{
    osThreadAttr_t attr;
    attr.name = "Gasdetection_task";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 1024;
    attr.priority = 25;

    if (osThreadNew(Gasdetection_task, NULL, &attr) == NULL) {
        printf("[Gasdetection_task] Falied to create Gasdetection_task!\n");
    }
}

SYS_RUN(Gasdetection_entry);